package com.bean;

public class SinhVien {
	private String mssv;
	private String hoten;
	private float diemthi;
	
	//cac phuong thuc get set
	public String getMssv() {
		return mssv;
	}
	public void setMssv(String mssv) {
		this.mssv = mssv;
	}
	public String getHoten() {
		return hoten;
	}
	public void setHoten(String hoten) {
		this.hoten = hoten;
	}
	public float getDiemthi() {
		return diemthi;
	}
	public void setDiemthi(float diemthi) {
		this.diemthi = diemthi;
	}
	
	//phuong thuc khai bao khong tham so
	public SinhVien(){
		this.setMssv(mssv);
		this.setHoten(hoten);
		this.setDiemthi(diemthi);
	}
	//phuong thuc khai bao 3 tham so
	public SinhVien(String mssv, String hoten, float diemthi){
		this.setMssv(mssv);
		this.setHoten(hoten);
		this.setDiemthi(diemthi);
	}
	//phuong thuc hien thi thong tin sinh vien
	public void hienthi(){
		System.out.println("|"+this.getMssv()+"|\t"+this.getHoten()+"\t|\t"+this.getDiemthi()+"\t|");
	}
	
	
	public static void main(String[] args){
		SinhVien s[];//khai bao mang doi tuong sinh vien
		s = new SinhVien[100];
		int x = Integer.parseInt(args[0]);//tong so sinh vien
		int i = 1;
		int j = 1;
		while(x>0){
			String mssv = String.valueOf(args[i++]);
			String hoten = String.valueOf(args[i++]);
			float diemthi = Float.parseFloat(args[i++]);
			s[j] = new SinhVien(mssv,hoten,diemthi);
			x--;
			j++;
		}
		//hien thi thong tin sinh vien
		System.out.println("_________________________________________________");
		System.out.println("|  MSSV  |         HO TEN       |    DIEM THI   |");
		System.out.println("|________|______________________|_______________|");
		for(int k=1;k<j;k++){
			s[k].hienthi();
		}
		System.out.println("|________|______________________|_______________|");
		
		
		float max = 0.0f; int imax=0;
		float min =10.0f; int imin=0;
		int count=0;
		float trungbinh=0f;
		float sum=0f;
		for(int k=1;k<j;k++){
			if(s[k].getDiemthi()>=max){ 
				max = s[k].getDiemthi();
				imax = k;
			}
		}
		
		for(int k=1;k<j;k++){
			if(s[k].getDiemthi()<=min){ 
				min = s[k].getDiemthi();
				imin = k;
			}
		}
		
		System.out.println("sinh vien co diem thi cao nhat: ");
		s[imax].hienthi();
		System.out.println("sinh vien co diem thi thap nhat: ");
		s[imin].hienthi();
		System.out.print("So luong sinh vien co diem >= 4: ");
		for(int k=1;k<j;k++){
			if(s[k].getDiemthi()>=4)count++;
		}
		System.out.println(count);
		for(int k=1;k<j;k++){
			sum=sum+s[k].getDiemthi();
		}
		trungbinh = sum/(j-1);
		System.out.printf("diem trung binh cua ca nhom la: %.2f",trungbinh);
	}
}

